package del1;

import java.util.*;

public class TextAnalyzer {
	public static void main(String[] args) {
		Text text = new Text();
		LinkedList list = text.getTextAsLinkedList();
		System.out.println(list.size());
		
		System.out.println(list.get(45));
		
		Set<String> duplicates = new HashSet<String>();
		duplicates.addAll(list);
		System.out.println(duplicates.size());
		
		Set<String> alfaset = new TreeSet<String>(list);
		for(String s : alfaset) {
			System.out.println(s);
		}
		
		Collections.sort(list);
		for(int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
		
		TreeMap<String, Integer> map = new TreeMap<String, Integer>();
		for(int i = 0; i < list.size(); i++) {
			String theString = (String) list.get(i);
			if(map.containsKey(theString)) {
				int k = map.get(theString);
				map.put(theString, k+1);
			} else {
				map.put(theString, 1);
			}
		}
		Set<String> mapSet = map.keySet();
		for(String s : mapSet) {
			System.out.println(s +"_"+map.get(s));
		}
	}
}
